<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class WaterLine extends Model
{
    protected $table = 't_water_pipeline';
    
    protected $primaryKey = 'id';
    
    protected $fillable = [ 'site_id', 'company_id', 'content', 'pipedot', 'pipepa', 'pipejing', 'water' ];
    
    protected $casts = [
        'site_id'=>'integer',
        'company_id'=>'integer',
        'content'=>'array',
        'pipedot'=>'array',
        'pipepa'=>'array',
        'pipejing'=>'array',
        'water'=>'array',
    ];
    
    public function setContentAttribute($value) {
        $this->attributes['content'] = json_encode($value);
    }
    
    public function setPipedotAttribute($value) {
        $this->attributes['pipedot'] = json_encode($value);
    }
    
    public function setPipepaAttribute($value) {
        $this->attributes['pipepa'] = json_encode($value);
    }
    
    public function setPipejingAttribute($value) {
        $this->attributes['pipejing'] = json_encode($value);
    }
    
    public function setWaterAttribute($value) {
        $this->attributes['water'] = json_encode($value);
    }
    
    public function setSiteIdAttribute($value) {
        $this->attributes['site_id'] = $value??0;
    }
    
}
